import stote from '@/vuex/store.js'
import coordtransform from 'coordtransform'

function plusReady() {
  plus.geolocation.watchPosition(function (p) {
    var gcj02tobd09 = coordtransform.gcj02tobd09(p.coords.longitude, p.coords.latitude);
    var datas = {
      lng: gcj02tobd09[0],
      lat: gcj02tobd09[1],
      city: p.address.city,                //城市
      cityCode: p.address.cityCode,        //城市区号
      country: p.address.country,          //国家
      district: p.address.district,        //县（区）
      poiName: p.address.poiName,          //周边公司
      province: p.address.province,        //省
      street: p.address.street,            //街道
      streetNum: p.address.streetNum       //门牌号
    };
    stote.commit("watchPosition", datas)
  }, function (e) {

  }, {coordsType: 'gcj02',maximumAge:'3000'});
}

if (window.plus) {
  plusReady();
} else {
  document.addEventListener("plusready", plusReady, false);
}
